package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class Order here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Order // the order class. Used to make order-objects
{
    
    //instance variables
    private int orderId;
    private double totalPrice;
    private Customer c;
    private ArrayList<PartOrder> partList;
    private boolean checkOut;

    /**
     * Constructor for objects of class Order
     */
    public Order(int orderId)
    {
        this.orderId = orderId;        
        partList = new ArrayList<PartOrder>();
        totalPrice = 0;
        checkOut = false;
    }
    
    public void addCustomer(Customer c) //adds a customer to the order
    {
         this.c = c;
    }
    
    public void addPartOrder(PartOrder pO)  // add partorders to the order
    {
        partList.add(pO);
    }
    
    private double totalPrice()  //calculates the price
    {
        totalPrice = 0;
        for(PartOrder pO : partList)
        {
            totalPrice += pO.getPrice();
        }
        return totalPrice;
    }
    
    public String getOrderId()  //returns the orders id
    {
        String id = ""+orderId;
        return id;
    }
    
    public void printAll()  //prints the order and the partorders
    {
        System.out.println("**** Order ID: "+orderId+" ****");
        System.out.println();
        System.out.println("Product(s): ");
        for(PartOrder pO : partList)
        {
            pO.showInfo();
            System.out.println("*****************");
        }
        System.out.println("Total: "+totalPrice());
    }
    
    public void checkOut() //checks out. Makes the checkout boolean true, which means we can ship the order, and recieve payment.
    {
        checkOut = true;
    }
    
    public Customer getCustomer() //returns customer
    {
        return c;
    }
}
